package ventanas;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import controladores.ControladorVentanaGenerarProximosTurnos;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.JButton;
import javax.swing.SpinnerNumberModel;
import negocio.Medico;

public class VentanaGenerarProximosTurnos extends JFrame {
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private final JLabel lblGenerarPrximosTurnos = new JLabel("Generar Pr\u00F3ximos Turnos");
	private final JLabel lblGenerarTurnosPor = new JLabel("Generar Turnos por los pr\u00F3ximos");
	private final JLabel lblMeses = new JLabel("Meses");
	private final JSpinner spinner = new JSpinner();
	private final JButton btnAceptar = new JButton("Aceptar");
	private final JButton btnCancelar = new JButton("Cancelar");
	private final JLabel lblParaElMdico = new JLabel("Para el m\u00E9dico");
	private final JLabel lblMedico = new JLabel("New label");
	private ControladorVentanaGenerarProximosTurnos controlador;
	private Medico medico;
	
	public VentanaGenerarProximosTurnos(Medico medico) {
		setTitle("Generaci\u00F3n de Turnos");
		this.medico = medico;
		this.controlador = new ControladorVentanaGenerarProximosTurnos(this);
		initGUI();
		cargarDatosPrevios();
		agregarListeners();
	}
	
	public void initGUI(){
		setBounds(100, 100, 353, 189);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FormLayout(new ColumnSpec[] {
				ColumnSpec.decode("max(111dlu;default)"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(30dlu;default)"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(129dlu;default)"),},
			new RowSpec[] {
				RowSpec.decode("max(19dlu;default)"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("max(31dlu;default)"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("max(21dlu;default)"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("max(27dlu;default)"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("max(31dlu;default)"),}));
		
		contentPane.add(lblGenerarPrximosTurnos, "1, 1, 5, 1");
		contentPane.add(lblGenerarTurnosPor, "1, 3");
		spinner.setModel(new SpinnerNumberModel(0, null, 24, 1));
		contentPane.add(spinner, "3, 3");
		contentPane.add(lblMeses, "5, 3, left, default");
		contentPane.add(lblParaElMdico, "1, 5");
		contentPane.add(lblMedico, "3, 5, 3, 1");
		contentPane.add(btnCancelar, "1, 7");
		contentPane.add(btnAceptar, "3, 7, 3, 1, fill, default");
		this.setVisible(true);
		this.setLocationRelativeTo(null);
		this.pack();
	}

	private void cargarDatosPrevios(){
		lblMedico.setText(medico.getNombre());
	}
	
	private void agregarListeners(){
		btnAceptar.addActionListener(controlador);
		btnCancelar.addActionListener(controlador);
	}
	
	//getters y setters
	public JSpinner getSpinner() {
		return spinner;
	}

	public JButton getBtnAceptar() {
		return btnAceptar;
	}

	public JButton getBtnCancelar() {
		return btnCancelar;
	}

	public Medico getMedico() {
		return medico;
	}

	public void setMedico(Medico medico) {
		this.medico = medico;
	}
}
